Closed Bug 1635970 Opened 5 years ago Closed 5 years ago

XPath search isn't working for some expressions

Categories

(DevTools :: Inspector, enhancement, P3)

enhancement

Tracking

(firefox79 verified)

VERIFIED FIXED
Firefox 79
Tracking Status
firefox79 --- verified

People

(Reporter: sebo, Assigned: sebo)

References

(Blocks 1 open bug, )

Details

Attachments

(2 files)

At Stack Overflow it was mentioned that it is currently not possible to find elements by index, that is for example (//div)[4] (the 4th <div> element in the document).

The reason for that is that is that the check for whether the search string is an XPath expression currently only covers strings starting with a slash.
Further research showed that also expressions like id("foo") (matching the element with ID foo) are valid.
Those expressions are working in the Chrome DevTools and I think it is reasonable to support them in Firefox, too.

Test case:

  1. Go to data:text/html,<div><p><div id="div2"></div><p></div>
  2. Open the DevTools Inspector
  3. Search for (//div[2]) or id("div2")

=> This should select the <div> element inside the <p> element.

To support them, the check could either be extended or be removed entirely. The latter would mean to always run the XPath search before the full text search, though, which might have performance implications.

Sebastian

Severity: -- → N/A
Type: defect → enhancement
Priority: -- → P3

The limitation to expressions starting with a slash was lifted in order to allow searching via other possible XPath expressions like id("foo") or (//div)[2].

Assignee: nobody → sebastianzartner
Status: NEW → ASSIGNED
Pushed by abutkovits@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/03154d974c8a Extended support for XPath expressions in Inspector search. r=jdescottes
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 79

Small gif of the implemented feature

Verified with 79.0b2 in Windows 10, macOS 10.15.5, Ubuntu 18.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: